package com.azt.novel.home.service.impl;


import com.azt.novel.common.resp.RestResp;
import com.azt.novel.home.resp.HomeBookRespDto;
import com.azt.novel.home.manager.HomeBookCacheManager;
import com.azt.novel.home.service.IHomeBookService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;

/**
 * <p>
 * 小说推荐 服务实现类
 * </p>
 *
 * @author azt
 * @since 2023-12-02
 */
@Service
public class HomeBookServiceImpl implements IHomeBookService {

    @Resource
    private HomeBookCacheManager homeBookCacheManager;


    @Override
    public RestResp<List<HomeBookRespDto>> listHomeBooks() {
        List<HomeBookRespDto> list = homeBookCacheManager.listHomeBooks();
        if(CollectionUtils.isEmpty(list)){
            homeBookCacheManager.evictCache();
        }
        return RestResp.ok(list);

    }
}
